import 'package:flutter/material.dart' hide TabBarView;
import 'package:flutter/cupertino.dart';
import 'body.dart';
import 'package:hairen_app/pages/tabView/my_tab_view.dart';
import 'package:hairen_app/pages/plug/drawer.dart';
import 'package:hairen_app/pages/search/search.dart';
import 'package:hairen_app/main.dart';

class IndexPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new IndexPageState();
}

class IndexPageState extends State<IndexPage> {

 BuildContext context;
 Scaffold scaffold;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void deactivate() {
    // TODO: implement deactivate
    super.deactivate();
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();

  }

  @override
  Widget build(BuildContext context) {
    this.context=context;
    return new DefaultTabController(
        length: 3,
        child: new Scaffold(
          appBar: new AppBar(
            title: new Container(
              width: 220.0,
              child: new TabBar(
                unselectedLabelColor:Colors.white,
                labelColor: Colors.white,
                indicatorWeight:0.1,
                indicatorPadding:EdgeInsets.all(.0),
                labelStyle:new TextStyle(fontSize: 18.0,fontWeight: FontWeight.bold),
//                indicatorColor: Color.fromRGBO(226, 226, 226,.5),
                unselectedLabelStyle:new TextStyle(fontSize: 14.0),
                tabs: <Widget>[
                  new Tab(
                    text: '最新',
                  ),
                  new Tab(
                    text: '热门',
                  ),
                  new Tab(
                    text: '推荐',
                  ),
                ],
//                            indicator: new ShapeDecoration(shape: new Border.all(color: Colors.redAccent, width: 1.0)),
                indicator: new ShapeDecoration(
                    shape: new Border(
                        bottom: new BorderSide(
                            width: 1.0,
                            color: Theme.of(context).backgroundColor))),
              ),
            ),
            actions: [
              new IconButton(
                  icon: new Icon(
                    Icons.search,
                    color: Colors.white,
                  ),
                  onPressed: (){
                    Navigator.of(context).push(
                      new CupertinoPageRoute(
                          fullscreenDialog:true,
                          builder: (context)=>new SearchPage()),
                    );
                  }),
            ],
          ),
          body: new TabBarView(
            children: <Widget>[
              new BodyPage(
                tid: 1,
              ),
              new BodyPage(
                tid: 2,
              ),
              new BodyPage(
                tid: 3,
              ),
            ],
          ), // This trailing comma makes auto-formatting nicer for build methods.
        ));
  }
}
